import Cookies from 'js-cookie'

const TokenKey = 'UID'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  if (process.env.NODE_ENV === 'development' || !cookiesDomain) {
    Cookies.set(TokenKey, token, {
      expires: 1
   })
   return
  }
  Cookies.set(TokenKey, token, {
     expires: 1,
     path: '/',
     domain: cookiesDomain
  })
}

export function removeToken() {
  if (process.env.NODE_ENV === 'development' || !cookiesDomain) {
    Cookies.remove(TokenKey)
    return
  }
  Cookies.remove(TokenKey, {
    path: '/',
    domain: cookiesDomain
 })
}
